#include "obstacle.h"
#include <QRandomGenerator>
#include <QGraphicsScene> //

Obstacle::Obstacle(int speed, QGraphicsItem *parent)
    : GameObject(parent), speed(speed)
{
    setPixmap(QPixmap(":/images/D:/obstacle.jpg").scaled(40, 40));
    int yPos = 300 - pixmap().height();
    setPos(800, yPos);
}

void Obstacle::update()
{
    setPos(x() - speed, y());

    if (x() + pixmap().width() < 0) {
        scene()->removeItem(this);
        delete this;
    }
}
